package org.springblade.feign;


import org.springblade.core.tool.api.R;
import org.springblade.dto.ProtocolAnalysisDTO;
import org.springblade.entity.Product;
import org.springblade.vo.ProductVO;
import org.springblade.vo.ProtocolAnalysisVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Feign接口类
 * @author Chill
 */
@FeignClient(
	value = "blade-device-manager"
)
public interface IDeviceManagerClient {
	String API_PREFIX = "/device-manager";
	String GETCONTROLLIST = "/getControlList";
	String GETPROTOCOLANALYSISLIST = API_PREFIX + "/getProtocolAnalysisList";
	String SENTCONTROLCMD = "/sentControlCmd";
	String UPDATEPROTOCOLDATA = API_PREFIX + "/updateProtocolData";
	String GETPROTOCOLANALYSISONE = API_PREFIX + "/getProtocolAnalysisOne";
	String GETPRODUCTONE = API_PREFIX + "/getProductOne";
	String INITCONNECT = API_PREFIX + "/initConnect";
	String UPDATEPROTOCOLSTATUS = API_PREFIX + "/updateProtocolStatus";
	String TESTIPANDPORT = API_PREFIX + "/testIpAndPort";

	/**
	 * 查询控制列表
	 * @param protocolAnalysisDTO
	 * @return
	 */
	@PostMapping(GETCONTROLLIST)
	List<ProtocolAnalysisVO> getControlList(ProtocolAnalysisDTO protocolAnalysisDTO);

	/**
	 * 推送控制命令，反馈控制结果状态码
	 * @param protocolAnalysisDTO
	 */
	@PostMapping(SENTCONTROLCMD)
	R<Boolean> sentControlCmd(ProtocolAnalysisDTO protocolAnalysisDTO);

	/**
	 * 获取协议列表
	 * @param address
	 * @param port
	 * @return
	 */
	@GetMapping(GETPROTOCOLANALYSISLIST)
	List<ProtocolAnalysisVO> getProtocolAnalysisList(@RequestParam("address") String address, @RequestParam("port") String port, @RequestParam("direction") Integer direction);

	/**
	 * 更新协议数据
	 * @param protocolAnalysisVO
	 */
	@PostMapping(UPDATEPROTOCOLDATA)
	void updateProtocolData(@RequestBody ProtocolAnalysisVO protocolAnalysisVO);

	/**
	 * 获取解码getOne
	 * @param protocolAnalysisId
	 * @return
	 */
	@GetMapping(GETPROTOCOLANALYSISONE)
	ProtocolAnalysisVO getProtocolAnalysisOne(@RequestParam("protocolAnalysisId") Long protocolAnalysisId);

	/**
	 * 产品查询GetOne
	 * @param address
	 * @param port
	 * @return
	 */
	@GetMapping(GETPRODUCTONE)
	ProductVO getProductOne(@RequestParam("address") String address, @RequestParam("port") String port);

	/**
	 * initConnect
	 * @return
	 */
	@GetMapping(INITCONNECT)
	List<ProductVO> initConnect();

	/**
	 * updateProtocolStatus
	 * @param product
	 */
	@PostMapping(UPDATEPROTOCOLSTATUS)
	void updateProtocolStatus(@RequestBody Product product);

	/**
	 * 测试产品连通性
	 */
	@GetMapping(TESTIPANDPORT)
    void testIpAndPort();
}
